Scientific workflows: Tools and Tips 🔨💡
5/11/23
📅 Every 3rd Thursday 🕓 4-5 p.m. 📍 Webex
Quarto is an open-source scientific and technical publishing system
Basic idea: Create documents with dynamic content and text
Document types that can be created with Quarto (examples):
Quarto is a huge topic and there are so many cool Quarto things out there!
Goal of today: Introduction to Quarto and an overview of different document types and their possibilities.
Different options, depending on your workflow
Help -> Check for Updates)quarto that provides an interface to Quarto (preconditions are Quarto CLI or new version of R Studio)Check out the Quarto website for download and more info.
Reproducible documents for data analysis
Download the demo project from Github
An HTML example
Problem: Manual updates are error prone and non-reproducible
Solution: Use a Quarto workflow everything (code, text, metadata) in one place. Let Quarto do the magic
Advantages of this workflow:
.qmd documentQuartoOpen R Studio and go to File -> New File -> Quarto Document
Just click Create and the file will open in R Studio.
In other environments you can just create and empty file with .qmd ending
You can edit:
Render button in R StudioCtrl + Shift + Kquarto::quarto_render() functionquarto render doc.qmdWhat happens during rendering?
Artwork from “Hello, Quarto” keynote by Julia Lowndes and Mine Çetinkaya-Rundel,presented at RStudio Conference 2022. Illustrated by Allison Horst.
.qmd documentText body, Code, YAML header
Markdown allows you to do simple things like
Or more complex things like:
If you don’t want to use markdown, there is a really nice feature in R Studio: The visual editor.
Convenient, word-like interface for formatting text and adding features.
Using the visual editor, makes many things that would be painful in Markdown really easy.
My favorite feature in the visual editor:
Insert -> Citation) from Zotero library, DOI search, PubMed, …Code can be included in code chunks as inline code
Inline code starts and ends with 1 backtick
`r `
Code chunks starts and ends with 3 backticks
```{r}
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess")
```Insert a code chunk
Insert a code chunk by going to Code -> Insert chunk
Use the keyboard shortcut Ctrl + Alt + I / Cmd + Option + I
Inline chunks have to be typed or use the </> symbol in visual mode
Run code chunk
Code chunks are evaluated by knitr when rendering the document
Code chunks can also be run like normal R code
Run Code chunk by clicking on the green arrow next to the chunk
Code chunk have special comments that start with #|, e.g.
```{r}
#| label: fig-airquality
#| fig-cap: Temperature and ozone level.
#| include: false
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess")
```label: Figure and chunk label that can be referred to in textfig-cap: Figure captioninclude: Include the output (i.e. the plot) in the document but don’t show the codeInclude an image from a code chunk via knitr::include_graphics().
```{r}
#| echo: false
#| out.width: "20%"
#| fig-align: center
#| fig-cap: Quarto logo
#| fig-cap-location: margin
knitr::include_graphics("images/2023_05_11_quarto/quarto_straight.png")
```Quarto logo
For document output formats
For document options
Execute options
Use cases for scientists
qmd instead of .R files to add text already to the code (e.g. for interpretation or methods)Quarto offers many more things like:
Git is an essential skill if you use any programming language. It allows you to keep track of changes over time, collaborate with others, and maintain a clear and organized file structure. This can save time, improve research efficiency, and makes it easy to publish your code.
📅 15th June 🕓 4-5 p.m. 📍 Webex
📧 For topic suggestions and/or feedback send me an email